package com.beta.cat.utils.sequence;

import com.beta.cat.service.impl.RedissonServiceImpl;
import com.beta.cat.utils.sequence.builder.RedisRadomSeqBuilder;
import com.beta.cat.utils.sequence.seq.Sequence;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.client.codec.StringCodec;
import org.redisson.config.Config;

/**
 * @author taofucheng
 * @date 2024/4/12
 */
public class Demo {
    public static void main(String[] args) {
        Config config = new Config();
        //默认编码 JsonJacksonCodec
        config.setCodec(new StringCodec());
        config.useSingleServer()
                .setAddress("redis://redis-dev.test.betawm.com:6379");

        RedissonClient redissonClient = Redisson.create(config);
        RedissonServiceImpl redissonService = new RedissonServiceImpl();
        redissonService.setRedissonClient(redissonClient);
        // redids Random
        Sequence sequence = RedisRadomSeqBuilder.create().redissonService(redissonService).length(10).bizName(
                "userId").build();
        for (int i = 0; i < 10; i++) {
            System.out.println(sequence.nextValue());
        }

        System.exit(0);
    }
}
